package com.adou.multi.model;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.adou.multi.domain.entiry.Product;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ProductValue {
	@JsonProperty("id")
	private Long id;
	
	@NotNull
	@Size(max =255)
	@JsonProperty("name")
	private String name;
	
	
	public static ProductValue fromEntity(Product product){
		return ProductValue.builder()
				.id(product.getId())
				.name(product.getName())
				.build();
	}
	
	public static Product fromEntity(ProductValue productValue){
		return Product.builder()
				.id(productValue.getId())
				.name(productValue.getName())
				.build();
	}
	
}
